home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Programmer Disk
/
The Programmer Disk (Microforum).iso
/
xpro
/
c2
/
pro4
/
hatch.c
< prev
next >
Wrap
Text File
|
1986-05-27
|
2KB
|
82 lines
/* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
#include <stdio.h>
#define EXTERN extern
#include <typedef.h>
void HatchDirect(x1, y1, x2, y2, Delta)
int x1, y1, x2, y2, Delta;
{
int i,yst,yen,count;
int X1RefLoc,X2RefLoc,Y1RefLoc,Y2RefLoc;
int DirectModeLoc,ClippingLoc;
int X1D,Y1D,X2D,Y2D;
if (Delta == 0)
return;
HatchGlb = TRUE;
DirectModeLoc = DirectModeGlb;
DirectModeGlb = TRUE;
ClippingLoc = ClippingGlb;
ClippingGlb = TRUE;
X1RefLoc = X1RefGlb;
X1RefGlb = x1;
X2RefLoc = X2RefGlb;
X2RefGlb = x2;
Y1RefLoc = Y1RefGlb;
Y1RefGlb = y1;
Y2RefLoc = Y2RefGlb;
Y2RefGlb = y2;
yst = y1 + Delta;
yen = y1 - x2 + x1 + Delta;
if (Delta < 0) {
Delta = -Delta;
i = yst;
yst = yen;
yen = i;
}
count = (int)((y2-y1+x2-x1+x2-x1) / Delta);
for (i = 1; i < count; i++ ) {
X1D = x1;
Y1D = yst;
X2D = x2;
Y2D = yen;
if (clip(&X1D, &Y1D, &X2D, &Y2D))
DrawLineDirect(X1D, Y1D, X2D, Y2D);
yst = yst + Delta;
yen = yen + Delta;
}
ClippingGlb = ClippingLoc;
HatchGlb = FALSE;
X1RefGlb = X1RefLoc;
X2RefGlb = X2RefLoc;
Y1RefGlb = Y1RefLoc;
Y2RefGlb = Y2RefLoc;
DirectModeGlb = DirectModeLoc;
}
void Hatch(X_1, Y_1, X_2, Y_2, Delta)
double X_1, Y_1, X_2, Y_2, Delta;
{
int x1, y1, x2, y2;
int DirectModeLoc;
if (DirectModeGlb)
HatchDirect((int)(X_1), (int)(Y_1), (int)(X_2), (int)(Y_2),
(int)(Delta));
else {
DirectModeLoc = DirectModeGlb;
DirectModeGlb = TRUE;
x1 = WindowX(X_1);
y1 = WindowY(Y_1);
x2 = WindowX(X_2);
y2 = WindowY(Y_2);
clip(&x1, &y1, &x2, &y1);
clip(&x1, &y1, &x1, &y2);
HatchDirect(x1, y1, x2, y2, (int)(Delta));
DirectModeGlb = DirectModeLoc;
}
}